{% extends 'main.html' %}

{% block title %}
<title>用户信息</title>
{% endblock %}

{% block content %}

        <div class="panel pos-rel col-lg-offset-3">

                                    <div class="col-sm-8">
					        <div class="panel hidden" id="pass_input" >
					            <!--Horizontal Form-->
					            <!--===================================================-->
                               <form method="POST" onsubmit="return check_pass()"  >
					                <div class="panel-body">
					                    <div class="form-group">
					                        <label class="col-sm-3 control-label" for="demo-hor-inputemail">密码</label>
					                        <div class="col-sm-9">
					                            <input type="password" placeholder="password" id="passwd1" class="form-control">
					                        </div>
					                    </div>
					                    <div class="form-group">
					                        <label class="col-sm-3 control-label" for="demo-hor-inputpass">再次确认</label>
					                        <div class="col-sm-9">
					                            <input type="password" placeholder="Password" id="passwd2" class="form-control" name="passwd">
					                        </div>
					                    </div>

					                </div>
                                           <div class="panel-footer text-right" >
                                               <i id="error_msg" style="color: red;" class="hidden">两次密码不一致，请重新输入</i>
                                               <button class="btn btn-danger" onclick="showpass()" type="button" >显示密码</button>
                                               <button class="btn btn-success" type="submit" >确认修改</button>
                                            </div>
                                   </form>


					            <!--===================================================-->
					            <!--End Horizontal Form-->

					        </div>
					    </div>
					                <div class="pad-all" id="info">
					                    <div class="media pad-ver">
					                        <div class="media-left">
					                            <a href="#" class="box-inline"><img alt="Profile Picture" class="img-md img-circle" src="/static/img/profile-photos/4.png"></a>
					                        </div>
					                        <div class="media-body pad-top">
					                            <a href="#" class="box-inline">
					                                <span class="text-lg text-semibold text-main">{{ request.user.name }}</span>
					                                <p class="text-sm">{{ request.user }}</p>
					                            </a>
					                        </div>
					                    </div>
					                    <p class="pad-btm bord-bt text-sm">是否管理员：{{ request.user.is_superuser }}</p>
                                        <p class="pad-btm bord-bt text-sm">最后一次登录：{{ request.user.last_login }}</p>
					                    <div class="text-center pad-to">
					                        <div class="btn-group center-block ">
					                            <a href="/logout/" class="btn btn-warning"><i class="demo-pli-consulting icon-lg icon-fw"></i> 注销</a>
					                           <button class="btn btn-purple" onclick="change_pass()">修改密码</button>
					                        </div>
					                    </div>
					                </div>
					            </div>

<script>
    function showpass(){
        $('#passwd1').attr('type','text');
        $('#passwd2').attr('type','text')
    }

    function change_pass(){
        $('#pass_input').removeClass('hidden');
        $('#info').hide();
    }

    function check_pass(){
        var passwd1=$('#passwd1').val();
        var passwd2=$('#passwd2').val();
        if (passwd1.trim().length == 0 ){
            alert('密码不能为空')
            return false
        }

        if (passwd1 == passwd2){
            alert('密码成功修改，请重新登陆！！');
            return true
        }else{
            $('#error_msg').removeClass('hidden');
            alert('两次密码输入不正确!');
            return false
        }
    }
</script>
{% endblock %}
